namespace PPM.Blog.Repository.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class addUserAndMenuAndRole : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.T_Menu",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 10),
                        Url = c.String(nullable: false, maxLength: 20),
                        Icon = c.String(maxLength: 20),
                        Description = c.String(maxLength: 1000),
                        State = c.Int(nullable: false),
                        CreatorId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        LastModifierId = c.Int(),
                        LastModifyTime = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Role",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ParentId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 10),
                        Code = c.String(nullable: false, maxLength: 10),
                        Level = c.String(maxLength: 20),
                        Path = c.String(maxLength: 20),
                        Description = c.String(maxLength: 1000),
                        State = c.Int(nullable: false),
                        CreatorId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        LastModifierId = c.Int(),
                        LastModifyTime = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Role", t => t.ParentId)
                .Index(t => t.ParentId);
            
            CreateTable(
                "dbo.T_User",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Account = c.String(nullable: false, maxLength: 10),
                        NickName = c.String(maxLength: 10),
                        Password = c.String(nullable: false, maxLength: 32),
                        Mobile = c.String(maxLength: 13),
                        Email = c.String(),
                        State = c.Int(nullable: false),
                        CreatorId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        LastModifierId = c.Int(),
                        LastModifyTime = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.T_Role", "ParentId", "dbo.T_Role");
            DropIndex("dbo.T_Role", new[] { "ParentId" });
            DropTable("dbo.T_User");
            DropTable("dbo.T_Role");
            DropTable("dbo.T_Menu");
        }
    }
}
